//*************************************************************************************
//* 作    者： 
//* 创建时间： 2021-10-25 08:09:48
//*  描    述：

//* ************************************************************************************
using System;
using UnityEngine;
using UFrame.Tween;
using System.Linq;
public class RollerPathMove :MonoBehaviour{
    [SerializeField]
    protected Transform m_roller;
    [SerializeField]
    protected Transform m_pathRoot;
    [SerializeField]
    protected float m_durection = 30;
    [SerializeField]
    protected TweenPath m_tweenPath;
    private void Start()
    {
        TweenAgent.Instance.StartTween(m_tweenPath);
    }

    private void OnDrawGizmos()
    {
        if (!m_pathRoot)
            return;

        if(m_tweenPath.path.Length != m_pathRoot.childCount)
        {
            m_tweenPath.path = new Vector3[m_pathRoot.childCount];
        }
        for (int i = 0; i < m_pathRoot.childCount; i++)
        {
            m_tweenPath.path[i] = m_pathRoot.GetChild(i).position;
        }
        m_tweenPath.OnDrawGizmos();
    }

    private void OnDestroy()
    {
        TweenAgent.Instance.StopTween(m_tweenPath);
    }
}
